<template>
  <div class="record">
      <van-list
        v-if="list.length"
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <van-card
          v-for="(item, index) in list"
          :key="index"
          :tag="statusDes[item.status]"
          :price="item.money"
          :desc="getDateTime(item.createTime)"
          :title="item.orderid"
          thumb="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2239375454,1397093940&fm=26&gp=0.jpg"
        />
      </van-list>
      <h2 v-else>暂无充值记录</h2>
  </div>
</template>

<script>
import {getPurchaseHistory} from '../../../../../api/api/index'
import moment from 'moment'
export default {
  data(){
    return {
      list: [],
      loading: false,
      finished: false,
      statusDes: ['申请中', '等待付款', '付款完成', '超时取消', '提现完成']
    }
  },
  created(){
    this.onLoad();
  },
  methods:{
    async onLoad(){
      //是否处于 loading状态
      this.loading = true;
      if (this.list.length === 0) {
        getPurchaseHistory().then(res => {
          if (res.code === 200) {
            this.list = res.data
          }
        })
        this.finished = true
      }
      this.loading = false
    },
    getDateTime(time) {
      return moment(time).format('YYYY-MM-DD HH:MM:SS')
    }
  }
}
</script>

<style>

</style>